import { createBrowserRouter } from 'react-router-dom';
import App from '../App';
import Home from '../pages/Home';
import Login from '../pages/Login';
import CartList from '../pages/CartList';
import Category from '../pages/Category';
import CategorySub from '../pages/CategorySub';
import Product from '../pages/Product';
import CreateOrder from '../pages/CreateOrder';
import User from '../pages/User';
import { Navigate } from 'react-router-dom';

const router = createBrowserRouter([
    {
        path: '/',
        element: <App />,
        children: [
            {
                path: '/home',
                element: <Home />
            },
            {
                path: '/user',
                element: <User />
            },
            {
                path: '/login',
                element: <Login />
            },
            {
                path: '/category',
                element: <Category />
            },
            {
                path: '/category/sub',
                element: <CategorySub />
            },
            {
                path: '/product',
                element: <Product />
            },
            {
                path: '/cartList',
                element: <CartList />
            },
            {
                path: '/createOrder',
                element: <CreateOrder />
            },
            {
                path: '/',
                element: <Navigate to="/home" replace />
            }
        ]
    }
]);

export default router;